home *** CD-ROM | disk | FTP | other *** search
- /*
- File: CAS_Content.h
-
- Contains: Data structures and routines to support document content elements
- and element collections. A content element in CASample is either
- a PICT element or an embedded frame.
-
- A content element collection implements the element record allocation
- scheme (currently uses a block allocation scheme)
-
- Written by: Rick Badertscher
-
- Copyright © 1993-1995 Apple Computer, All rights reserved.
-
- Change History (most recent first):
-
- <2> 11/14/95 RB Added clipping support
- <1> 9/1/95 RB Created.
- */
-
- #if !defined(_H_CAS_Content)
- #define _H_CAS_Content
-
- #include "CAS_Types.h"
-
- //---------------------------------------------------------------------------
- // Forward Declarations
- //---------------------------------------------------------------------------
-
- //---------------------------------------------------------------------------
- // Content Element Types
- //---------------------------------------------------------------------------
-
- #define kNULLElemType 'NULL'
- #define kFrameElemType 'PART'
-
- // ElemColl_FindElem result codes
- enum
- {
- inElement = 0,
- inCornerResize = 1,
- inEdgeResize = 2
- };
-
- typedef enum {kNone, kTL, kTR, kBL, kBR, kTE, kBE, kRE, kLE} ResizeHandle;
-
- #define kBorderWidth 5
-
- //---------------------------------------------------------------------------
- // Data Structures
- //---------------------------------------------------------------------------
-
- typedef struct
- {
- RgnHandle cornerHandleRgn;
- RgnHandle edgeHandleRgn;
- RgnHandle selectRgn;
- } SelRgnRec, *SelRgnRecPtr;
-
-
- // Element Record
-
- struct ElemRec
- {
- OSType elemType;
- Handle elemData;
- Boolean resizable;
- Boolean selected;
- Point location;
- Rect contentRect; // In document coordinates
- SelRgnRec selRgn;
- ElemCollPtr collection;
- Boolean visible;
- RgnHandle clipRgn;
- Boolean clipInvalid;
- };
-
-
- // Element Node
-
- struct ElemNode
- {
- ElemPtr elemPtr;
- ElemNodePtr nextNode;
- };
-
- struct ElemList
- {
- ElemNodePtr headNode;
- ElemNodePtr tailNode;
- short count;
- };
-
- // Element Collection
-
- struct ElemColl
- {
- DocPtr docPtr;
- short count;
- ElemList elemList;
- };
-
-
- // a ElemPtr is passed to each routine, theElem can be either rellocatable or not
-
- ElemPtr Elem_New ( Handle data,
- OSType type,
- Rect contentRect,
- Point location);
-
- ElemPtr Elem_Read ( IOStreamPtr ioStream);
-
-
- OSErr Elem_Write ( ElemPtr, IOStreamPtr ioStream);
- long Elem_SpaceRequired( ElemPtr);
- ElemPtr Elem_Clone ( ElemPtr);
-
- void Elem_UpdateCAFrame( ElemPtr);
- void Elem_UpdateCAVisFrame( ElemPtr);
-
- void Elem_Remove( ElemPtr);
- void Elem_Free( ElemPtr);
-
- void Elem_GetLocation( ElemPtr, Point* location);
- void Elem_SetLocation( ElemPtr, Point location);
-
- void Elem_SetRect( ElemPtr, Rect contentRect);
- void Elem_GetRect( ElemPtr, Rect* contentRect);
- void Elem_GetLocatedRect( ElemPtr, Rect* contentRect);
- void Elem_GetDisplayRect( ElemPtr, Rect* displayRect);
-
- void Elem_SetSelected( ElemPtr, Boolean selected);
- Boolean Elem_GetSelected( ElemPtr);
-
- OSType Elem_GetType( ElemPtr);
-
- void Elem_SetVisible( ElemPtr theElem, Boolean visible);
-
- void Elem_Invalidate( ElemPtr);
- void Elem_Draw( ElemPtr, Boolean drawSel);
-
- void Elem_InvalClipRgn ( ElemPtr);
- void Elem_CalcClipRgn( ElemPtr);
-
- void Elem_DrawSelRgn( ElemPtr);
- void Elem_InvalSelRgn( ElemPtr);
- void Elem_CalcSelRgn( ElemPtr);
-
- Boolean Elem_HandleMouseDown( ElemPtr, DocPtr, EventRecord*);
-
- void Elem_HandleMouseInCornerResize ( ElemPtr elem,
- DocPtr docPtr,
- Point* mouse,
- EventRecord* event);
-
- void Elem_HandleMouseInEdgeResize ( ElemPtr theElem,
- DocPtr theDoc,
- Point* mouse,
- EventRecord* event);
-
-
- // Element Collection
- void ElemColl_Init( ElemCollPtr, DocPtr theDoc);
-
- void ElemColl_AddElem( ElemCollPtr, ElemPtr theElem);
- void ElemColl_AddElemTemp( ElemCollPtr, ElemPtr theElem);
-
- void ElemColl_Free( ElemCollPtr);
- void ElemColl_FreeAll( ElemCollPtr);
-
- void ElemColl_ClipElements( ElemCollPtr, Rect* clipArea);
- void ElemColl_RemoveElem( ElemCollPtr, ElemPtr theElem);
- short ElemColl_GetCount( ElemCollPtr);
- ElemPtr ElemColl_GetNthElem( ElemCollPtr, short index);
-
- short ElemColl_GetCountOfType( ElemCollPtr, OSType elemType);
- ElemPtr ElemColl_GetNthElemOfType( ElemCollPtr, short index, OSType type);
-
- short ElemColl_FindElem( ElemCollPtr, Point mouse, ElemPtr* theElem);
- DocPtr ElemColl_GetDocPtr( ElemCollPtr);
-
- // Z-order functions.
- void ElemColl_MoveElemToFront( ElemCollPtr, ElemPtr);
- void ElemColl_GetRgnOverElem( ElemCollPtr, ElemPtr, RgnHandle);
-
- ElemListPtr ElemColl_GetCurrentSelection (ElemCollPtr);
-
- // ElemList
- //
- // An ElemList is a single linked list of ElemNode structures.
- // The list order represents the zorder. The tail node is the top most layer.
-
- void ElemList_Init ( ElemListPtr theList);
- void ElemList_Free( ElemListPtr theList);
- void ElemList_AddNode ( ElemListPtr theList, ElemNodePtr theNode);
- ElemNodePtr ElemList_RemoveNode ( ElemListPtr theList, ElemPtr theElem);
- ElemNodePtr ElemList_GetNode ( ElemListPtr theList, ElemPtr theElem);
- ElemNodePtr ElemList_GetHeadNode ( ElemListPtr theList);
- short ElemList_GetCount( ElemListPtr);
- ElemPtr ElemList_GetNthElem( ElemListPtr, short index);
-
-
- #endif
-
-